 /**************************************************************************
 * MODULE NAME:    l2_primitives.h
 * PROJECT CODE:
 * DESCRIPTION:    l2cap API
 * MAINTAINER:     Martin Mellody
 * DATE:           02-12-1999
 *
 * SOURCE CONTROL: $Id: l2cap_primitives.h,v 1.1.1.1 2007/12/18 05:32:40 tianwq Exp $
 *
 * LICENSE:
 *     This source code is copyright (c) 2000-2002 RDA Microelectronics, Ltd.
 *     All rights reserved.
 *
 * SOURCE: 
 *
 *************************************************************************/

/*
    WARNING::

    Some of these structure types are visible on the API and 
    therefore MUST match the declarations in user/l2cap.h. 
*/

#ifndef __L2CAP_PRIMITIVES_H
#define __L2CAP_PRIMITIVES_H

#include "host_config.h"
#include "host_msg.h"
#include "l2_types.h"


enum {
    L2CAP_evCONNECTIND= L2CAP_MSG_BASE,
    L2CAP_evCONNECTCONF,
    L2CAP_evCONFIGUREIND,
    L2CAP_evCONFIGURECONF,
    L2CAP_evDISCONNECTIND,
    L2CAP_evDISCONNECTCONF,
    L2CAP_evQOSVIOLATIONIND,
    L2CAP_evDATAIND,
    L2CAP_evBUFFEROVERFLOW,
    L2CAP_evFLUSHOCCURRED,
    L2CAP_evTIMEOUTIND,
    L2CAP_evCONNCONFIGUREDCONF,

    L2CAP_RESEND_DATA
};


typedef struct l2cap_cbs l2_callbacks;

typedef struct L2_ChannelFlowSpec t_L2_ChannelFlowSpec;
typedef struct L2_ConfigReqParams t_L2_ConfigReqParams;


APIDECL1 t_api APIDECL2 L2_Connect(t_bdaddr BDAddress, u_int16 psm, u_int8 module_id);
APIDECL1 t_api APIDECL2 L2_ConnectResponse(t_bdaddr BDAddress, u_int16 cid, u_int16 response, u_int16 status);


APIDECL1 t_api APIDECL2 L2_Configure(u_int16 cid, u_int16 inMTU, u_int16 outFlushTimeout, u_int16 linkTimeout, t_L2_ChannelFlowSpec *outflow);
APIDECL1 t_api APIDECL2 L2_ConfigureResponse(u_int16 cid, u_int16 outMTU, u_int16 response, t_L2_ChannelFlowSpec *inflow);

#if RDABT_L2CAP_AUTO_CONFIG==1
APIDECL1 t_api APIDECL2 L2_ConnectandConfig(t_bdaddr bdaddr, u_int16 psm, u_int8 module_id, t_L2_ConfigReqParams *req_params);
APIDECL1 t_api APIDECL2 L2_ConnectResponseandConfig(t_bdaddr bdaddr, u_int16 cid, u_int16 response, u_int16 status, t_L2_ConfigReqParams *req_params);
#endif

APIDECL1 t_api APIDECL2 L2_Disconnect(u_int16 cid);

APIDECL1 t_api APIDECL2 L2_RetrieveHandle(u_int16 cid, u_int16* handle);

APIDECL1 t_api APIDECL2 L2_DisableConnectionlessTraffic(u_int16 psm);
APIDECL1 t_api APIDECL2 L2_EnableConnectionlessTraffic(u_int16 psm);

APIDECL1 t_api APIDECL2 L2_GetWriteBuffer(u_int16 cid, u_int16 len, t_DataBuf **writeBuffer);
APIDECL1 t_api APIDECL2 L2_Get_Flushable_WriteBuffer(u_int16 cid, u_int16 len, t_DataBuf **writeBuffer);

APIDECL1 t_api APIDECL2 L2_Write(u_int16 cid, t_DataBuf *writeBuffer); 
APIDECL1 t_api APIDECL2 L2_FreeWriteBuffer(t_DataBuf *writeBuffer); 
APIDECL1 t_api APIDECL2 L2_HaveBuffer(u_int16 cid,u_int16 len);

#if (L2CAP_GROUPS_SUPPORTED==1)
APIDECL1 t_api APIDECL2 L2_GroupCreate(u_int16 psm, u_int16 *cid);
APIDECL1 t_api APIDECL2 L2_GroupClose(u_int16 cid);

APIDECL1 t_api APIDECL2 L2_GroupAddMember(u_int16 group_cid, t_bdaddr bdaddr, void (*addMemberCfm)(u_int16 cid, t_bdaddr bdaddr, u_int16 result));

APIDECL1 t_api APIDECL2 L2_GroupRemoveMember(u_int16 cid, t_bdaddr bdaddr);
APIDECL1 t_api APIDECL2 L2_GroupGetMembers(u_int16 group_cid,t_bdaddr *addrList, u_int16* addrListLen);
#endif

#if (L2CAP_PING_SUPPORTED==1)
APIDECL1 t_api APIDECL2 L2_Ping(t_bdaddr BDAddress,u_int8 *echoData, u_int16 length, void (*callbackFunc)(t_bdaddr BDAddress, u_int16 result, u_int8 *echoData, u_int16 length));
#endif

#if (L2CAP_INFO_SUPPORTED==1)
APIDECL1 t_api APIDECL2 L2_GetInfo(t_bdaddr BDAddress, u_int16 infoType, void (*callbackFunc)(t_bdaddr BDAddress,u_int16 result, u_int8* infoData,u_int16 infoLen)); 
#endif

void L2_Dont_Send_Disconnect_Rsp(void);
void L2_Dont_Send_Echo_Response(void);

/* Internal stack buffer allocation functions */
t_api rdabt_l2_GetWriteBuffer(u_int16 cid, u_int16 len, u_int32 flags, rdabt_host_buf_t **writeBuffer);
t_api rdabt_l2_FreeWriteBuffer(rdabt_host_buf_t *writeBuffer);


#endif /* __L2CAP_API_H */
 

